package reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class ReflectDemo3 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
        Person p1 = new Person();
        System.out.println(p1);

        Person p2 = new Person("惠惠","2岁");
        System.out.println(p2);

        Class cls = Class.forName("reflect.Person");
        Constructor constructor = cls.getConstructor(String.class, String.class);
        Object o = constructor.newInstance("小春", "3岁");
        System.out.println(o);

    }
}
